<?php

include 'header.php';

?>
<h4>Player Registration</h4>

<?php
include 'config.php';
include 'opendb.php';

if(isset($_POST['add']))
{


$name = mysql_real_escape_string($_POST['name'], $conn);
$email = mysql_real_escape_string($_POST['email'], $conn);
$password = mysql_real_escape_string($_POST['password'], $conn);
$cpassword = mysql_real_escape_string($_POST['cpassword'], $conn);

if($password == $cpassword){

$password = md5($password);

$prequery= "INSERT INTO PLAYER SET NAME='$name', PASSWORD='$password', EMAIL='$email';";
mysql_query($prequery, $conn) or die('Error, player add failed. Try a new name.');		
				
echo "Player Added";
}
else{

echo "Two password fields do not match.";

}


}
else
{
?>
<p>Please fill out the following information to add youself as a player</p>
<br>
<form method="post">
<table width="450" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="200">Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td width="200">Email</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td width="200">Password</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td width="200">Confirm Password</td>
<td><input name="cpassword" type="password" id="cpassword"></td>
</tr>
<tr>
<td width="200">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="200">&nbsp;</td>
<td><input name="add" type="submit" id="add" value="Add New Player"></td>
</tr>
</table>
</form>
<?php
}
?>

<?php
include 'closedb.php';
include 'footer.php';
?>